﻿// lindexi
// 10:37

using ArticleandSiteData;
using HtmlAgilityPack;
using ModelClassLibrary;
using Newtonsoft.Json;
using modle;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Net.Http;
using System.Runtime.Serialization.Json;
using System.Threading.Tasks;
using Windows.ApplicationModel.Activation;
using Windows.ApplicationModel.Core;
using Windows.Devices.Geolocation;
using Windows.Foundation;
using Windows.Foundation.Metadata;
using Windows.System;
using Windows.System.Profile;
using Windows.UI.Core;
using Windows.UI.Popups;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
using Windows.UI;
using Windows.Networking.Connectivity;
using Windows.Networking;
using Windows.Storage;
using Windows.UI.Xaml.Input;
using Walterlv.Colorful.Models;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409

namespace SplitViewOptions
{
    //public delegate void tranferbtnclick(object sender, RoutedEventArgs e);

    public static class MyEvent
    {
        public static EventHandler<RoutedEventArgs> BtnEvent
        {
            set;
            get;
        }

        public static void FireEvent(object sender, RoutedEventArgs e)
        {
            BtnEvent?.Invoke(sender, e);
        }
    }

    /// <summary>
    ///     An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
            this.Loaded += MainPage_Loaded;
            CurrentView.BackRequested += CurrentView_BackRequested;
            App.Titlebox = autoSuggestBox;
            App.Mainframe = this.MainFrame;
            //if (AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Desktop")
            //{
            //    ApplicationView.PreferredLaunchViewSize = new Size(480, 680);
            //    ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;
            //    // ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(768, 1365));
            //}
            App.Mainmenugrid = menumaingrid;
            App.Tooltipgrid = tooltipgrid;
            MySplitView.IsPaneOpen = false;
        }

        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            autoSuggestBox.Text = string.Empty;
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var args = e.Parameter as FileActivatedEventArgs;
            searchbtn.Focus(FocusState.Programmatic);
            // autoSuggestBox.Focus(FocusState.Unfocused);
            if (args != null)
            {
                string name = args.Files[0].Name;
                var file = args.Files[0] as StorageFile;
                if (name.EndsWith("html") || name.EndsWith("htm") || name.EndsWith("cshtml"))
                {
                    MainFrame.Navigate(typeof(localhtmlPage), args);
                }
                else if (file != null && file.FileType == ".txt")
                {
                    MainFrame.Navigate(typeof(lindexi.uwp.Clenjw.View.Preface), file);
                }
                else
                {
                    MainFrame.Navigate(typeof(textPlainRecievePage), args);
                }
                return;
            }
            base.OnNavigatedTo(e);
            string jsonstr = string.Empty;
            //if (App.ismobile)
            //{
            this.MainFrame.Navigate(typeof(Desktop));
            return;

            // IsWindows10OrGreater
            //  ALLSitesResult resultlist =await  BmobWebsiteData.GetAllwebsitesinfoone<ALLSitesResult>(App.getallsiteurl);
            if (string.IsNullOrEmpty(jsonstr))
            {
                //  return;
            }
            // @"{ ""url"": ""http://cili006.com/""}"；
            jsonstr = "{" + "\"" + "url" + "\"" + ":" + "\"" + _lllurl + "\"" + "," + "\"" + "name" + "\"" + ":" + "\"" +
                      _name + "\"" + "}";
            // var responce = await BmobWebsiteData.AddoneWebsite<ALLSitesResult>(App.getallsiteurl, jsonstr);
            // App.currenturl = new Uri(App.homesiteurl, UriKind.RelativeOrAbsolute);
            // loadwebsitehtml();
            //  Debug.WriteLine(Version.)
            MySplitView.IsPaneOpen = false;
        }

        /// <summary>
        /// 当点击主导航按钮时发生，保留 SplitView 并导航到相应页面。
        /// </summary>
        //private void MainNavigationListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        //{
        //    PageNavigationItem item = (PageNavigationItem) MainNavigationListView.SelectedItem;
        //    if (item == null) return;

        //    MainFrame.Navigate(item.Type);
        //}

        /// <summary>
        /// 当点击系统导航按钮时发生，导航到相应页面。
        /// </summary>
        //private void SystemNavigationListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        //{
        //    PageNavigationItem item = (PageNavigationItem) SystemNavigationListView.SelectedItem;
        //    if (item == null) return;
        //    SystemNavigationListView.SelectedItem = null;

        //    Frame.Navigate(item.Type);
        //}

        private string _lllurl = "http://www.letv.com/";
        private string _name = "lll";
        private ObservableCollection<String> suggestions = new ObservableCollection<string>();

        private SystemNavigationManager CurrentView
        {
            set;
            get;
        } = SystemNavigationManager.GetForCurrentView();

        private async void CurrentView_BackRequested(object sender, BackRequestedEventArgs e)
        {
            if (MainFrame.CurrentSourcePageType == typeof(HomePage))
            {
                if (App.Secondwebview != null)
                {
                    if (App.Secondwebview.CanGoBack)
                    {
                        App.Secondwebview.GoBack();
                        e.Handled = true;
                        return;
                    }
                }
                if (App.Webview != null)
                {
                    if (App.Webview.CanGoBack)
                    {
                        if (App.Picnel != null)
                        {
                            App.Picnel.Visibility = Visibility.Collapsed;
                        }
                        //App.isgoingback = true;
                        App.Webview.GoBack();
                        e.Handled = true;
                        return;
                    }

                    else
                    {
                        e.Handled = true;
                        if (MainFrame.CanGoBack)
                        {
                            if (App.key > 0)
                            {
                                MainFrame.GoBack();
                                return;
                            }
                            else
                            {
                                App.key = App.key + 1;
                                return;
                            }
                        }
                        var dialog = new ContentDialog()
                        {
                            Title = "消息提示",
                            Content = "你确认要退出该页面吗?",
                            PrimaryButtonText = "确定",
                            SecondaryButtonText = "取消",
                            FullSizeDesired = false,
                        };

                        dialog.PrimaryButtonClick += (s, _e) =>
                        {
                            Application.Current.Exit();
                        };
                        dialog.SecondaryButtonClick += (s, _e) =>
                        {
                        };

                        await dialog.ShowAsync();

                        return;
                    }
                }
                else
                {
                    e.Handled = true;
                    if (MainFrame.CanGoBack)
                    {
                        MainFrame.GoBack();
                        return;
                    }
                    var dialog = new ContentDialog()
                    {
                        Title = "消息提示",
                        Content = "你确认要退出该页面吗?",
                        PrimaryButtonText = "确定",
                        SecondaryButtonText = "取消",
                        FullSizeDesired = false,
                    };

                    dialog.PrimaryButtonClick += (s, _e) =>
                    {
                        Application.Current.Exit();
                    };
                    dialog.SecondaryButtonClick += (_s, _e) =>
                    {
                    };
                    await dialog.ShowAsync();
                }
            }
            else
            {
                e.Handled = true;
                if (MainFrame.CanGoBack)
                {
                    MainFrame.GoBack();
                    return;
                }
                var dialog = new ContentDialog()
                {
                    Title = "消息提示",
                    Content = "你确认要退出该页面吗?",
                    PrimaryButtonText = "确定",
                    SecondaryButtonText = "取消",
                    FullSizeDesired = false,
                };

                dialog.PrimaryButtonClick += (_s, _e) =>
                {
                    Application.Current.Exit();
                };
                dialog.SecondaryButtonClick += (s, _e) =>
                {
                };
                await dialog.ShowAsync();
            }
        }

        private async void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            var statusbar = "Windows.UI.ViewManagement.StatusBar";
            if (ApiInformation.IsTypePresent(statusbar))
            {
                StatusBar.GetForCurrentView().BackgroundColor = Colors.White;
                await StatusBar.GetForCurrentView().ShowAsync();
                // 需要引用Windows Mobile Extensions for the UWP
                StatusBar statusBar = StatusBar.GetForCurrentView();
                // 背景色设置为需要颜色
                ApplicationView.GetForCurrentView().FullScreenSystemOverlayMode = FullScreenSystemOverlayMode.Standard;
                // Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().TryEnterFullScreenMode();

                statusBar.ForegroundColor = Colors.Black;
                statusBar.BackgroundOpacity = 1;

                // Windows.UI.ViewManagement.StatusBar.GetForCurrentView().OccludedRect.
            }
            // await Getlocation();
            GetLocalIp();
        }

        private void LoadWebsiteHtml()
        {
            if (MainFrame.CurrentSourcePageType == typeof(HomePage))
            {
                // App.webview.Navigate(App.currenturl);
                if (App.Ismobile)
                {
                    App.Navigatemobilemode(App.Webview, App.Currenturl);
                }
                else
                {
                    App.Webview.Navigate(App.Currenturl);
                }
            }
            else
            {
                this.MainFrame.Navigate(typeof(HomePage));
            }
        }

        private void HamburgerButton_Click(object sender, RoutedEventArgs e)
        {
            this.MySplitView.IsPaneOpen = !this.MySplitView.IsPaneOpen;
            //  App.mainmenugrid.Visibility = (App.mainmenugrid.Visibility == Visibility.Visible) ? Visibility.Collapsed : Visibility.Visible;
        }

        private void RadioButtonPaneItem_Click(object sender, RoutedEventArgs e)
        {
            MySplitView.IsPaneOpen = false;
            var radioButton = sender as RadioButton;

            if (radioButton != null)
            {
                switch (radioButton.Tag.ToString())
                {
                    case "Map":
                        this.MainFrame.Navigate(typeof(MapPage));
                        break;
                }
            }
        }

        private void LoginRadioButton(object sender, RoutedEventArgs e)
        {
            MySplitView.IsPaneOpen = false;
            MainFrame.Navigate(typeof(LoginPage));
        }

        private void Mostusedpage(object sender, RoutedEventArgs e)
        {
            MySplitView.IsPaneOpen = false;
            MainFrame.Navigate(typeof(AddmostusedPage));
        }

        private void Navigateclick(object sender, RoutedEventArgs e)
        {
            MySplitView.IsPaneOpen = false;
            MainFrame.Navigate(typeof(NavigatePage));
        }

        private void Homeclick(object sender, RoutedEventArgs e)
        {
            MySplitView.IsPaneOpen = false;
            //App.currenturl = new Uri(App.homesiteurl, UriKind.RelativeOrAbsolute);
            //loadwebsitehtml();
            // MainFrame.Navigate(typeof(HomePage));
            this.MainFrame.Navigate(typeof(Desktop));
            return;
        }

        private void Myfavorate(object sender, RoutedEventArgs e)
        {
            MySplitView.IsPaneOpen = false;
            this.MainFrame.Navigate(App.Loginuser != null ? typeof(MyfavoratePage) : typeof(LoginPage));
        }

        private void searchbtn_Click(object sender, RoutedEventArgs e)
        {
            MySplitView.IsPaneOpen = false;
            string text = autoSuggestBox.Text;
            if (string.IsNullOrEmpty(text))
            {
                string url = "https://www.baidu.com/";

                App.Currenturl = new Uri(url, UriKind.RelativeOrAbsolute);
            }
            else
            {
                string url = "https://www.baidu.com/s?wd=" + text;
                App.Currenturl = new Uri(url, UriKind.RelativeOrAbsolute);
            }


            // MainFrame.Navigate(typeof(HomePage));
            //  homewebview.Navigate(new Uri(url, UriKind.RelativeOrAbsolute));
            LoadWebsiteHtml();
        }

        private void openbtn_Click(object sender, RoutedEventArgs e)
        {
            Flyout f = this.openbtn.Flyout as Flyout;
            f?.Hide();
            MySplitView.IsPaneOpen = false;
            string str = autoSuggestBox.Text;
            if (str.StartsWith("http"))
            {
                //   Uri oneuri = new Uri(str, UriKind.RelativeOrAbsolute);

                App.Currenturl = new Uri(str, UriKind.RelativeOrAbsolute);
                // MainFrame.Navigate(typeof(HomePage));
                LoadWebsiteHtml();
            }
            else if (autoSuggestBox.Text.StartsWith("www"))
            {
                App.Currenturl = new Uri("http://" + autoSuggestBox.Text, UriKind.Absolute);
                // MainFrame.Navigate(typeof(HomePage));
                LoadWebsiteHtml();
            }
            else
            {
            }
        }

        private void Aboutclick(object sender, RoutedEventArgs e)
        {
            MySplitView.IsPaneOpen = false;
            MainFrame.Navigate(typeof(AboutPage));
        }

        private async void AutoSuggestBox_QuerySubmitted(AutoSuggestBox sender,
            AutoSuggestBoxQuerySubmittedEventArgs args)
        {
            try
            {
                if (args.ChosenSuggestion != null)
                {
                    string sargsstr = args.ChosenSuggestion.ToString();
                    if (sargsstr.StartsWith("http"))
                    {
                    }
                    else if (sargsstr.StartsWith("搜索"))
                    {
                        string url = "https://www.baidu.com/s?wd=" + sargsstr.Split(':')[1];
                    }
                    else if (sargsstr.StartsWith("搜图片"))
                    {
                        string url = "http://image.baidu.com/search/index?tn=baiduimage&word=" + sargsstr.Split(':')[1];
                    }
                    else if (sargsstr.StartsWith("搜视频"))
                    {
                        string url = "http://www.soku.com/search_video/q_" + sargsstr.Split(':')[1];
                    }
                    else
                    {
                    }
                    App.Currenturl = new Uri(sargsstr, UriKind.RelativeOrAbsolute);
                    LoadWebsiteHtml();
                    //  MainFrame.Navigate(typeof(HomePage));
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                await App.showmessage(ex.Message + "输入不对");
                //           MessageDialog pop = new MessageDialog(ex.Message + "输入不对");
                //await   pop.ShowAsync();
            }
        }

        private void AutoSuggestBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
        {
            suggestions.Clear();
            string str = sender.Text;
            if (str.StartsWith("http") || str.StartsWith("www"))
            {
            }
            else
            {
                suggestions.Add("http://www." + sender.Text + ".com");
                suggestions.Add("http://www." + sender.Text + ".cn");
                suggestions.Add("http://www." + sender.Text + ".net");
                suggestions.Add("http://www." + sender.Text + ".com.cn");
                suggestions.Add("http://www." + sender.Text + ".info");
                suggestions.Add("http://www." + sender.Text + ".me");
                suggestions.Add("http://wap." + sender.Text + ".com");
                suggestions.Add("http://wap." + sender.Text + ".cn");
                suggestions.Add("http://m." + sender.Text + ".cn");
                //suggestions.Add("搜索:" + sender.Text );
                //suggestions.Add("搜图片:" + sender.Text);
                //suggestions.Add("搜视频:" + sender.Text);
                sender.ItemsSource = suggestions;
            }
            Flyout f = searchbtn.Flyout as Flyout;
            if (f != null)
            {
                //f.ShowAt(autoSuggestBox);
            }
        }

        private async void autoSuggestBox_KeyDown(object sender, KeyRoutedEventArgs e)
        {
            try
            {
                if ((e.Key == VirtualKey.Enter) || (e.Key == VirtualKey.Accept) || (e.Key == VirtualKey.Execute))
                {
                    if (autoSuggestBox.Text.StartsWith("http"))
                    {
                        //   Uri oneuri = new Uri(str, UriKind.RelativeOrAbsolute);

                        App.Currenturl = new Uri(autoSuggestBox.Text, UriKind.RelativeOrAbsolute);
                        // MainFrame.Navigate(typeof(HomePage));
                        LoadWebsiteHtml();
                    }
                    else if (autoSuggestBox.Text.StartsWith("www"))
                    {
                        App.Currenturl = new Uri("http://" + autoSuggestBox.Text, UriKind.Absolute);
                        // MainFrame.Navigate(typeof(HomePage));
                        LoadWebsiteHtml();
                    }
                    else
                    {
                        string text = autoSuggestBox.Text;
                        string url = "https://www.baidu.com/s?wd=" + text;

                        App.Currenturl = new Uri(url, UriKind.RelativeOrAbsolute);
                        //MainFrame.Navigate(typeof(HomePage));
                        LoadWebsiteHtml();
                    }
                }
            }
            catch (Exception ex)
            {
                await App.showmessage(ex.Message + "输入不对");
                //MessageDialog pop = new MessageDialog(ex.Message + "输入不对");
                //await pop.ShowAsync();
            }
        }

        private void picbtn_Click(object sender, RoutedEventArgs e)
        {
            string word = autoSuggestBox.Text;
            Flyout f = moresearch.Flyout as Flyout;
            f?.Hide();
            string str;
            string content = (sender as Button)?.Content?.ToString();
            if (App.Ismobile)
            {
                switch (content)
                {
                    case "图片":
                        str = "http://cn.bing.com/images/search?q=" + word;
                        break;
                    case "搜狗":
                        str = "http://www.sogou.com/web?query=" + word;
                        break;
                    case "360搜":
                        str = "http://www.haosou.com/s?q=" + word;
                        break;
                    case "bing":
                        str = "http://global.bing.com/search?q=" + word;
                        break;
                    case "bing中国":
                        str = "http://cn.bing.com/search?q=" + word;
                        break;
                    case "google":
                        str = "https://www.google.com/#&q=" + word;
                        break;
                    case "google中国":
                        str = "https://www.google.com.hk/#&q=" + word;
                        break;
                    case "视频":
                        str = "http://v.baidu.com/v?ct=301989888&s=25&word=" + word;
                        break;
                    case "地图":
                        str = "http://map.baidu.com/";
                        break;
                    case "百科":
                        str = "http://baike.baidu.com/search/word?word=" + word;
                        break;
                    case "贴吧":
                        str = "http://tieba.baidu.com/f?ie=utf-8&fr=bks0000&kw=" + word;
                        break;
                    case "知道":
                        str = "http://zhidao.baidu.com/search?ct=17&pn=0&tn=ikaslist&rn=10&word=" + word;
                        break;
                    case "文库":
                        str = "http://wenku.baidu.com/search?word=" + word;
                        break;
                    default:
                        str = "http://baidu.com/";
                        break;
                }
            }
            else
            {
                switch (content)
                {
                    case "图片":
                        str = "http://cn.bing.com/images/search?q=" + word;
                        break;
                    case "视频":
                        str = "http://v.baidu.com/v?ct=301989888&s=25&word=" + word;
                        break;
                    case "地图":
                        str = "http://map.baidu.com/";
                        break;
                    case "百科":
                        str = "http://baike.baidu.com/search/word?word=" + word;
                        break;
                    case "贴吧":
                        str = "http://tieba.baidu.com/f?ie=utf-8&fr=bks0000&kw=" + word;
                        break;
                    case "知道":
                        str = "http://zhidao.baidu.com/search?ct=17&pn=0&tn=ikaslist&rn=10&word=" + word;
                        break;
                    case "文库":
                        str = "http://wenku.baidu.com/search?word=" + word;
                        break;
                    case "搜狗":
                        str = "http://www.sogou.com/web?query=" + word;
                        break;
                    case "360搜":
                        str = "http://www.haosou.com/s?q=" + word;
                        break;
                    case "bing":
                        str = "http://global.bing.com/search?q=" + word;
                        break;
                    case "bing中国":
                        str = "http://cn.bing.com/search?q=" + word;
                        break;
                    case "google":
                        str = "https://www.google.com/#&q=" + word;
                        break;
                    case "google中国":
                        str = "https://www.google.com.hk/#&q=" + word;
                        break;
                    default:
                        str = "http://baidu.com/";
                        break;
                }
            }
            App.Currenturl = new Uri(str, UriKind.RelativeOrAbsolute);
            LoadWebsiteHtml();
        }

        private void autoSuggestBox_KeyUp(object sender, KeyRoutedEventArgs e)
        {
            if ((e.Key == VirtualKey.None) || (e.Key == VirtualKey.Enter))
            {
                if (autoSuggestBox.Text.StartsWith("http"))
                {
                    //   Uri oneuri = new Uri(str, UriKind.RelativeOrAbsolute);

                    App.Currenturl = new Uri(autoSuggestBox.Text, UriKind.Absolute);
                    // MainFrame.Navigate(typeof(HomePage));
                    LoadWebsiteHtml();
                }
                else if (autoSuggestBox.Text.StartsWith("www"))
                {
                    App.Currenturl = new Uri("http://" + autoSuggestBox.Text, UriKind.Absolute);
                    // MainFrame.Navigate(typeof(HomePage));
                    LoadWebsiteHtml();
                }
                else
                {
                    string text = autoSuggestBox.Text;
                    string url = "https://www.baidu.com/s?wd=" + text;

                    App.Currenturl = new Uri(url, UriKind.RelativeOrAbsolute);
                    //MainFrame.Navigate(typeof(HomePage));
                    LoadWebsiteHtml();
                }
            }
        }

        private void RadioButton_Click(object sender, RoutedEventArgs e)
        {
        }

        private void Lianxianread(object sender, RoutedEventArgs e)
        {
            MySplitView.IsPaneOpen = false;
            //if (App.loginuser != null)
            //{
            //    this.MainFrame.Navigate(typeof(Lixianread));
            //}
            //else
            //{
            //    this.MainFrame.Navigate(typeof(Lixianread));
            //}
        }

        private void Top100Click(object sender, RoutedEventArgs e)
        {
            MySplitView.IsPaneOpen = false;
            this.MainFrame.Navigate(typeof(Top100page));
        }

        private void Historyclick(object sender, RoutedEventArgs e)
        {
            MySplitView.IsPaneOpen = false;
            this.MainFrame.Navigate(typeof(HistoryPage));
        }

        private void showmenu_Click(object sender, RoutedEventArgs e)
        {
            //Flyout f = this.openbtn.Flyout as Flyout;
            //if (f != null)
            //{
            //    f.Hide();
            //}
            MyEvent.FireEvent(sender,e);
        }


        private void double_Click(object sender, RoutedEventArgs e)
        {
            Flyout f = openbtn.Flyout as Flyout;
            f?.Hide();
            MyEvent.FireEvent(sender, e);
        }

        private void quitbtn_Click(object sender, RoutedEventArgs e)
        {
            CoreApplication.Exit();
        }

        private void Showtopmenu(object sender, RoutedEventArgs e)
        {
            MySplitView.IsPaneOpen = false;
            App.Isfully = !App.Isfully;

            if (App.Mainmenugrid.Visibility == Visibility.Visible)
            {
                App.Mainmenugrid.Visibility = Visibility.Collapsed;
            }
            else
            {
                App.Mainmenugrid.Visibility = Visibility.Visible;
            }
        }

        private async void Rateclick(object sender, RoutedEventArgs e)
        {
            MySplitView.IsPaneOpen = false;
            string str = "ms-windows-store://review/?ProductId=9nblggh6f2w5";
            await Launcher.LaunchUriAsync(new Uri(str));
        }

        /// <summary>
        ///     获取本地ip地址
        /// </summary>
        /// <returns>ip</returns>
        private static string GetLocalIp()
        {
            var icp = NetworkInformation.GetInternetConnectionProfile();
            if (icp?.NetworkAdapter == null)
            {
                return null;
            }
            var hostname = NetworkInformation.GetHostNames();
            foreach (HostName localHostName in NetworkInformation.GetHostNames())
            {
                if (localHostName.IPInformation != null)
                {
                    if (localHostName.Type == HostNameType.Ipv4)
                    {
                        string Text = localHostName.ToString();
                        return Text;
                        break;
                    }
                }
            }
            return "";
            //    .(hn =>
            //        hn.IPInformation?.NetworkAdapter != null && hn.IPInformation.NetworkAdapter.NetworkAdapterId
            //        == icp.NetworkAdapter.NetworkAdapterId);
            //// the ip address
            //return hostname?.CanonicalName;
        }

        private void Showbottommenu(object sender, RoutedEventArgs e)
        {
            if (App.Menutoatlpicnel != null)
            {
                App.Menutoatlpicnel.Visibility = Visibility.Visible;
            }
            else
            {
                if (App.Menutoatlpicnel != null)
                {
                    App.Menutoatlpicnel.Visibility = Visibility.Collapsed;
                }
            }
        }

        private void Edituserinfo(object sender, RoutedEventArgs e)
        {
            MySplitView.IsPaneOpen = false;
            MainFrame.Navigate(typeof(EditUserinfoPage));
        }

        public void liulanrecord_Click(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;
            if (btn != null)
            {
                btn.Content = "待开发";
            }
        }

        private void Uploadpic(object sender, RoutedEventArgs e)
        {
            MySplitView.IsPaneOpen = false;
            MainFrame.Navigate(typeof(UploadpicPage));
        }
    }
}